# -*- coding: utf-8 -*-
from django import forms
from django.forms import Form, ModelForm, PasswordInput, CharField, ChoiceField, FileField, ModelMultipleChoiceField, CheckboxSelectMultiple
from labmin.webapp.models import *


class StudentForm(ModelForm):
    class Meta:
        model = Student

class StudentGroupForm(ModelForm):
    description = CharField(widget=forms.Textarea, label='Opis', required=False)
    students = ModelMultipleChoiceField(widget=CheckboxSelectMultiple, queryset=Student.objects.all(), label='Studenci');
    class Meta:
        model = StudentGroup

class AdminForm(ModelForm):
    service_groups = ModelMultipleChoiceField(widget=CheckboxSelectMultiple, queryset=ServiceGroup.objects.all(), label='Grupy usług', required=False);
    student_groups = ModelMultipleChoiceField(widget=CheckboxSelectMultiple, queryset=StudentGroup.objects.all(), label='Grupy studentów', required=False);
    password = CharField(widget=PasswordInput, label='Hasło')
    class Meta:
        model = Admin

class ServiceForm(ModelForm):
    description = CharField(widget=forms.Textarea, label='Opis', required=False)
    class Meta:
        model = Service

class ServiceGroupForm(ModelForm):
    description = CharField(widget=forms.Textarea, label='Opis', required=False)
    services = ModelMultipleChoiceField(widget=CheckboxSelectMultiple, queryset=Service.objects.all(), label='Usługi');
    class Meta:
        model = ServiceGroup

class StudentServiceAssociationForm(Form):
    student_groups = []
    for group in StudentGroup.objects.all():
        student_groups = student_groups + [[group.name, group]]
    
    service_groups = []
    for group in ServiceGroup.objects.all():
        service_groups = service_groups + [[group.name, group]]
    
    student_group = ChoiceField(label='Grupa studentów', choices=student_groups)
    service_group = ChoiceField(label='Grupa usług', choices=service_groups)